package com.ywk.pattern._27_interpreter;

public class Main {
    public static void main(String[] args) {
        PlayContext playContext = new PlayContext();
        playContext.setText("T 600 O 2 E 0.5 T 300 G 1 ");
        Expression expression = null;
        try {
            while (playContext.getText().length() > 0) {
                String str = playContext.getText().substring(0, 1);
                switch (str) {
                    case "O":
                        expression = new Scale();
                        break;

                    case "T":
                        expression = new Speed();
                        break;
                    case "C":
                    case "D":
                    case "E":
                    case "F":
                    case "G":
                    case "A":
                    case "B":
                    case "P":
                        expression = new Note();
                        break;
                }
                expression.interpret(playContext);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
